package com.seda.fdc.ejb.reports.pdfgenerator.lowagie.text.image;

import java.io.IOException;
import java.net.MalformedURLException;

import com.lowagie.text.BadElementException;
import com.lowagie.text.DocumentException; 
import com.lowagie.text.pdf.PdfContentByte;

public class AbstractImage {
	com.lowagie.text.Image image;
	
	public AbstractImage(String path) throws BadElementException, MalformedURLException, IOException{
		this.image = com.lowagie.text.Image.getInstance(path);
	}
	
	public AbstractImage(byte[] buffer) throws BadElementException, MalformedURLException, IOException {
		this.image = com.lowagie.text.Image.getInstance(buffer);
	}
	
	public void scaleAbsolute(float newWidth, float newHeight){
		image.scaleAbsolute(newWidth, newHeight);
	}

	public void scalePercent(float percent){
		image.scalePercent(percent);
	}
 
	public void scaleToFit(float fitWidth, float fitHeight){
		image.scaleToFit(fitWidth, fitHeight);
	}	

	public void scaleToFitWidth(float fitWidth){
		image.scaleToFit(fitWidth,  image.getHeight()/image.getWidth() *  fitWidth);
	}		
	
	public void setAbsolutePosition(float x, float y, PdfContentByte content) throws DocumentException{
		image.setAbsolutePosition(x,y);
		content.addImage(image);
	}
	 
	public void setInitialRotation(float initialRotation) {
		image.setInitialRotation(initialRotation);
	}
	
	
}
